package com.zx.idc.backend.gui.api.ftp.watch;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.util.concurrent.TimeUnit;

/**
 * 监视文件变化的配置类
 *
 * @author rxliuli
 */
@ConfigurationProperties(prefix = "ftp.watch")
@Component
public class FtpWatchConfig {
    private static final int DEFAULT_INTERVAL = 10000;
    private static final String DEFAULT_PATH = "/999";
    private static final TimeUnit DEFAULT_BASE_UNIT = TimeUnit.MILLISECONDS;
    private static final int DEFAULT_BASE_TIMEOUT = 10;
    private static final boolean DEFAULT_BASE_ENABLE = false;
    /**
     * 扫描间隔时间单位，默认为毫秒
     */
    private final TimeUnit unit;
    /**
     * 扫描间隔，默认为 10000
     */
    private Integer interval;
    /**
     * 扫描的目录，默认为 999
     */
    private String path;
    /**
     * 超时时间，以分钟计算，默认为 10 分钟
     */
    private Integer timeout;

    private boolean enable;

    public FtpWatchConfig() {
        this.unit = DEFAULT_BASE_UNIT;
        this.interval = DEFAULT_INTERVAL;
        this.path = DEFAULT_PATH;
        this.timeout = DEFAULT_BASE_TIMEOUT;
        this.enable = DEFAULT_BASE_ENABLE;
    }

    public TimeUnit getUnit() {
        return unit;
    }

    public Integer getInterval() {
        return interval;
    }

    public FtpWatchConfig setInterval(Integer interval) {
        this.interval = interval;
        return this;
    }

    public String getPath() {
        return path;
    }

    public FtpWatchConfig setPath(String path) {
        this.path = path;
        return this;
    }

    public Integer getTimeout() {
        return timeout;
    }

    public FtpWatchConfig setTimeout(Integer timeout) {
        this.timeout = timeout;
        return this;
    }

    public boolean isEnable() {
        return enable;
    }

    public FtpWatchConfig setEnable(boolean enable) {
        this.enable = enable;
        return this;
    }
}
